package com.cskaoyan.bean;

import java.lang.reflect.Method;

/**
 * @author stone
 * @date 2021/11/16 16:51
 */
public class CustomDynamicProxy {

    Method m1;
    Method m2;
    Method m3;
    {
        try {
            m1 = Class.forName("com.cskaoyan.bean.Ray").getDeclaredMethod("buyBreakFast");
            m2 = Class.forName("com.cskaoyan.bean.Ray").getDeclaredMethod("drink");
            m3 = Class.forName("com.cskaoyan.bean.Ray").getDeclaredMethod("playBall", String.class);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    Support support = new Support();

    public void buyBreakFast() {
        support.method(m1,new Object[]{});
    }

    public void drink() {
        support.method(m2, new Object[]{});
    }

    public void playBall(String name) {
        support.method(m3,new Object[]{name});
    }
}
